﻿<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <title>百度地图离线API V2.0</title>
    <style type="text/css">
        body, html, #map_demo, #tab, #mapfrm {
            width: 100%;
            height: 100%;
            overflow: hidden;
            margin: 0;
            font-family: "微软雅黑";
        }

        #menu {
            height: 100%;
            overflow-y: auto;
        }

        td {
            font-size: 14px;
        }

        h4 {
            margin: 0;
        }

        #map_demo1, #map_demo2 {
            height: 50%;
        }
        .BMap_pop {
        color:#0d445f;
        }
    </style>
    <script type="text/javascript" src="../Baidu_JS/baidumap_api_function.js"></script>
</head>
<body>
    <div id="map_demo"></div>
</body>
</html>
<script type="text/javascript">
    // 百度地图API功能
    var map = initMap("map_demo");


  
    
    //创建无事件标点
    var marker = new BMap.Marker(new BMap.Point(106.5710895, 29.5589925));
    var iconc = new BMap.Icon("../Baidu_JS/images/marker_red_sprite.png", new BMap.Size(40, 34));
    marker.setIcon(iconc);
    map.addOverlay(marker); //将标记添加到地图中

    //创建有事件标点
    var point2 = new BMap.Point(106.5730895, 29.5589925);
    marker = new BMap.Marker(point2);
    iconc = new BMap.Icon("../Baidu_JS/images/marker_red_sprite.png", new BMap.Size(40, 34));
    marker.setIcon(iconc);
    map.addOverlay(marker); //将标记添加到地图中

    var infoWindow = new BMap.InfoWindow("test", {
        position: point2,    // 指定文本标注所在的地理位置
        offset: new BMap.Size(5, -5)    //设置文本偏移量
    });  // 创建信息窗口对象
    marker.addEventListener("click", function (e) {
        console.log(e);
        map.openInfoWindow(infoWindow, point2);
        
    });

    //文件文本标识
    var point3 = new BMap.Point(106.5760895, 29.5589925);
    var opts = {
        position: point3,    // 指定文本标注所在的地理位置
        offset: new BMap.Size(5, -5)    //设置文本偏移量
    }
    var label = new BMap.Label("<div>hello Test</div>", opts);  // 创建文本标注对象
    label.setStyle({
        color: "red",
        fontSize: "12px",
        height: "40px",
        lineHeight: "20px",
        fontFamily: "微软雅黑"
    });
    map.addOverlay(label);

    //添加画线覆盖
   var  arrPois = [
              new BMap.Point(106.5770895, 29.552),
              new BMap.Point(106.5780895, 29.553),
              new BMap.Point(106.5790895, 29.554),
              new BMap.Point(106.5800895, 29.555),
              new BMap.Point(106.5810895, 29.554),
              new BMap.Point(106.5820895, 29.553),
              new BMap.Point(106.5830895, 29.552),
              new BMap.Point(106.5840895, 29.551),
              new BMap.Point(106.5850895, 29.552)
    ];
    map.addOverlay(new BMap.Polyline(arrPois, { strokeColor: "blue", strokeWeight: 6, strokeOpacity: 0.5 }));
    map.setViewport(arrPois);


    
    map.addEventListener('click', function (e) {
    console.log('点击位置经纬度：' + e.point.lng + ',' + e.point.lat);
    });
    if (window.parent) {
        window.parent.mapObject = map;
        window.parent.BMap = BMap;
    }
   
</script>